package com.business_clean.ui.activity;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.view.WindowManager;

import com.blankj.utilcode.util.AppUtils;
import com.blankj.utilcode.util.ScreenUtils;
import com.business_clean.R;
import com.business_clean.app.base.BaseActivity;
import com.business_clean.app.callback.FetchAccessTokenCallBackImpl;
import com.business_clean.app.config.Constant;
import com.business_clean.app.config.ConstantMMVK;
import com.business_clean.app.flutter.FlutterManager;
import com.business_clean.app.network.NetUrl;
import com.business_clean.app.uitl.ActivityForwardUtil;
import com.business_clean.app.uitl.MMKVHelper;
import com.business_clean.databinding.ActivityStartBinding;
import com.business_clean.ui.activity.login.LoginActivity;
import com.business_clean.ui.activity.main.MainActivity;
import com.idsmanager.doraemonlibrary.DoraemonManager;
import com.idsmanager.doraemonlibrary.callback.DoraemonCallback;

import me.hgj.mvvmhelper.base.BaseViewModel;
import me.hgj.mvvmhelper.base.Ktx;
import me.hgj.mvvmhelper.base.KtxKt;
import me.hgj.mvvmhelper.ext.AppExtKt;
import me.hgj.mvvmhelper.ext.LogExtKt;

/**
 * 启动界面
 */
public class StartActivity extends BaseActivity<BaseViewModel, ActivityStartBinding> {

    private String TAG = "StartActivity";

    @Override
    public void initView(@Nullable Bundle savedInstanceState) {
        NetUrl.defaultUrl = MMKVHelper.getString(ConstantMMVK.ENVIRONMENT_BASE_URL, NetUrl.SERVER_URL_RELEASE);

        if (NetUrl.defaultUrl.equals(NetUrl.SERVER_URL_RELEASE)) {
            FlutterManager.sServerType = FlutterManager.SERVER_TYPE_RELEASE;
        } else if (NetUrl.defaultUrl.equals(NetUrl.SERVER_URL_TEST)) {
            FlutterManager.sServerType = FlutterManager.SERVER_TYPE_TEST;
        } else {
            FlutterManager.sServerType = FlutterManager.SERVER_TYPE_DEV;
        }

        ScreenUtils.setFullScreen(StartActivity.this);
        LogExtKt.logE("获取应用签名的的 SHA1 值 --> " + AppUtils.getAppSignaturesSHA1(), TAG);
        LogExtKt.logE("获取应用签名的的 SHA256 值 --> " + AppUtils.getAppSignaturesSHA256(), TAG);
        LogExtKt.logE("获取应用签名的的 MD5 值 --> " + AppUtils.getAppSignaturesMD5(), TAG);

        if (!TextUtils.isEmpty(MMKVHelper.getString(ConstantMMVK.TOKEN))) {
            ActivityForwardUtil.startActivity(MainActivity.class);
        } else {
            ActivityForwardUtil.startActivity(LoginActivity.class);
        }
        AppExtKt.finishActivity(StartActivity.class);
    }


}